﻿function ClientAddGroupFunction()
{
    RoleId = document.getElementById("divSelectRole").options[document.getElementById("divSelectRole").selectedIndex].value;
    belongSite = document.getElementById("drpSelectSiteForGroupFunction").options[document.getElementById("drpSelectSiteForGroupFunction").selectedIndex].value;

    Url = Portal.SystemWebParts.GroupFunction.GroupFunction.GetAddGroupNewUrl(belongSite,  RoleId).value;
    window.open(Url, '_blank');
    //window.showModalDialog(Url, null, 'dialogHeight: 600px; dialogWidth: 800px; dialogTop: 10px; dialogLeft: 150px; edge: Raised; center: Yes; help: No; scroll: Yes; status: Yes;'); 
    //RealJumpPageGroupFunction();
}


function ClientAddGroupFunctionForOffice() {
    RoleId = document.getElementById("divSelectRole").options[document.getElementById("divSelectRole").selectedIndex].value;
    Url = Portal.SystemWebParts.GroupFunction.GroupFunctionForOffice.GetAddGroupNewUrl(RoleId).value;
    window.showModalDialog(Url, null, 'dialogHeight: 600px; dialogWidth: 800px; dialogTop: 10px; dialogLeft: 150px; edge: Raised; center: Yes; help: No; scroll: Yes; status: Yes;');
    RealJumpPageGroupFunctionForOffice();
}


function ClientSaveAddGroupFunction(RoleId) {
    BelongSite = document.getElementById("txtBelongSite").value;
    Subject=document.getElementById("txtGroupFunction").value;
    GroupIndex = document.getElementById("txtGroupIndex").value;
    
    SiteIndex = document.getElementById("drpSelectSite").selectedIndex;
    SiteCode = document.getElementById("drpSelectSite").options[SiteIndex].value;

    TemplateFileIndex = document.getElementById("drpSelectTemplateFile").selectedIndex;
    TemplateFile = document.getElementById("drpSelectTemplateFile").options[TemplateFileIndex].value;

    RetValue = Portal.SystemWebParts.GroupFunction.AddGroupFunction.ServerSideAddGroupFunction(BelongSite, RoleId, Subject, GroupIndex, SiteCode, TemplateFile).value;
    if(RetValue.indexOf("ERROR")!=-1)
    {
        alert(RetValue);
        return;
    }
    alert(RetValue);
    window.close();
}


function ClientSaveAddGroupFunctionForOffice(RoleId) {
    Subject = document.getElementById("txtGroupFunction").value;
    GroupIndex = document.getElementById("txtGroupIndex").value;
    RetValue = Portal.SystemWebParts.GroupFunction.AddGroupFunctionForOffice.ServerSideAddGroupFunction(RoleId, Subject, GroupIndex).value;
    if (RetValue.indexOf("ERROR") != -1) {
        alert(RetValue);
        return;
    }
    alert(RetValue);
    window.close();
}

function ClientDeleteGroupFunction(GroupFunctionId)
{
    Msg=Portal.SystemWebParts.GroupFunction.GroupFunction.GetConfirmDeleteMsg().value;
    if(confirm(Msg)==false)return;
    RetValue = Portal.SystemWebParts.GroupFunction.GroupFunction.ServerSideDeleteGroupFunction(GroupFunctionId).value;
    if(RetValue.indexOf("ERROR")!=-1)
    {
        alert(RetValue);
        return;
    }
    alert(RetValue);
    RealJumpPageGroupFunction();
}


function ClientDeleteGroupFunctionForOffice(GroupFunctionId) {
    Msg = Portal.SystemWebParts.GroupFunction.GroupFunctionForOffice.GetConfirmDeleteMsg().value;
    if (confirm(Msg) == false) return;
    RetValue = Portal.SystemWebParts.GroupFunction.GroupFunctionForOffice.ServerSideDeleteGroupFunction(GroupFunctionId).value;
    if (RetValue.indexOf("ERROR") != -1) {
        alert(RetValue);
        return;
    }
    alert(RetValue);
    RealJumpPageGroupFunctionForOffice();
}

function ShowClientUpdateUrlForm(GroupFunctionId)
{
    Url=Portal.SystemWebParts.GroupFunction.GroupFunction.GetShowUpdateForm(GroupFunctionId).value;
    if(Url.indexOf("ERROR")!=-1)
    {
        alert(Url);
        return;
    }
    //window.showModalDialog(Url, null, 'dialogHeight: 600px; dialogWidth: 800px; dialogTop: 10px; dialogLeft: 150px; edge: Raised; center: Yes; help: No; scroll: Yes; status: Yes;');
    window.open(Url, '_blank');
    //RealJumpPageGroupFunction();
}


function ShowClientUpdateUrlFormForOffice(GroupFunctionId) {
    Url = Portal.SystemWebParts.GroupFunction.GroupFunctionForOffice.GetShowUpdateForm(GroupFunctionId).value;
    if (Url.indexOf("ERROR") != -1) {
        alert(Url);
        return;
    }
    window.showModalDialog(Url, null, 'dialogHeight: 600px; dialogWidth: 800px; dialogTop: 10px; dialogLeft: 150px; edge: Raised; center: Yes; help: No; scroll: Yes; status: Yes;');
    RealJumpPageGroupFunctionForOffice();
}

function ClientSaveUpdateGroupFunction(GroupFunctionId)
{
    Subject=document.getElementById("txtGroupFunction").value;
    GroupIndex = document.getElementById("txtGroupIndex").value;
    SiteIndex = document.getElementById("drpSelectSite").selectedIndex;
    SiteCode = document.getElementById("drpSelectSite").options[SiteIndex].value;
    RetValue = Portal.SystemWebParts.GroupFunction.UpdateGroupFunction.ServerSideUpdateGroupFunction(GroupFunctionId, Subject, GroupIndex, SiteCode).value;
    if(RetValue.indexOf("ERROR")!=-1)
    {
        alert(RetValue);
        return;
    }
    alert(RetValue);
    window.close();
}

function ClientSaveUpdateGroupFunctionForOffice(GroupFunctionId) {
    Subject = document.getElementById("txtGroupFunction").value;
    GroupIndex = document.getElementById("txtGroupIndex").value;
    RetValue = Portal.SystemWebParts.GroupFunction.UpdateGroupFunctionForOffice.ServerSideUpdateGroupFunction(GroupFunctionId, Subject, GroupIndex).value;
    if (RetValue.indexOf("ERROR") != -1) {
        alert(RetValue);
        return;
    }
    alert(RetValue);
    window.close();
}


function JumPageGroupFunction()
{
    document.getElementById("divProcessing").innerHTML=Portal.SystemWebParts.GroupFunction.GroupFunction.GetProcessingText().value;
    setTimeout("RealJumpPageGroupFunction()",10);
}

function RealJumpPageGroupFunction()
{
    PageIndex=0;
    if(document.getElementById("divSelectPageGroupFunction")!=null)
    {   
        PageIndex=document.getElementById("divSelectPageGroupFunction").selectedIndex;
    }
    RoleId = document.getElementById("divSelectRole").options[document.getElementById("divSelectRole").selectedIndex].value;
    belongSite = document.getElementById("drpSelectSiteForGroupFunction").options[document.getElementById("drpSelectSiteForGroupFunction").selectedIndex].value;

    retValue = Portal.SystemWebParts.GroupFunction.GroupFunction.GetHtml(belongSite, RoleId, PageIndex).value;
    if(retValue.indexOf("ERROR")!=-1)
    {
        alert(retValue);
        return;
    }
    document.getElementById("divProcessing").innerHTML="";
    document.getElementById("divGroupFunctionMain").innerHTML=retValue;
}



function JumPageGroupFunctionForOffice() {
    document.getElementById("divProcessing").innerHTML = Portal.SystemWebParts.GroupFunction.GroupFunctionForOffice.GetProcessingText().value;
    setTimeout("RealJumpPageGroupFunctionForOffice()", 10);
}

function RealJumpPageGroupFunctionForOffice() {
    PageIndex = 0;
    if (document.getElementById("divSelectPageGroupFunction") != null) {
        PageIndex = document.getElementById("divSelectPageGroupFunction").selectedIndex;
    }
    RoleId = document.getElementById("divSelectRole").options[document.getElementById("divSelectRole").selectedIndex].value;
    retValue = Portal.SystemWebParts.GroupFunction.GroupFunctionForOffice.GetHtml(RoleId, PageIndex).value;
    if (retValue.indexOf("ERROR") != -1) {
        alert(retValue);
        return;
    }
    document.getElementById("divProcessing").innerHTML = "";
    document.getElementById("divGroupFunctionMain").innerHTML = retValue;
}

function ClientShowFunctionForm(GroupFunctionId)
{
    Url=Portal.SystemWebParts.GroupFunction.GroupFunction.GetShowFunctionForm(GroupFunctionId).value;
    if(Url.indexOf("ERROR")!=-1)
    {
        alert(Url);
        return;
    }
    window.open(Url, "_blank");
}

function ClientShowFunctionFormForOffice(GroupFunctionId) {
    Url = Portal.SystemWebParts.GroupFunction.GroupFunctionForOffice.GetShowFunctionForm(GroupFunctionId).value;
    if (Url.indexOf("ERROR") != -1) {
        alert(Url);
        return;
    }
    window.showModalDialog(Url, null, 'dialogHeight: 600px; dialogWidth: 800px; dialogTop: 10px; dialogLeft: 150px; edge: Raised; center: Yes; help: No; scroll: Yes; status: Yes;');
}



function JumPageAvailableGroupFunction(GroupFunctionId) {
    document.getElementById("divProcessingAvailable").innerHTML=Portal.SystemWebParts.GroupFunction.Functions.GetProcessingText().value;
    setTimeout("RealJumPageAvailableGroupFunction('"+GroupFunctionId+"')",10);
}

function RealJumPageAvailableGroupFunction(GroupFunctionId)
{
    PageIndex=0;
    if(document.getElementById("divSelectAvailableGroupFunction")!=null)
    {   
        PageIndex=document.getElementById("divSelectAvailableGroupFunction").selectedIndex;
    }
    Keyword = document.getElementById("txtAvailableKeyword").value;
    ShowAll = document.getElementById("chkShowAll").checked;

    retValue = Portal.SystemWebParts.GroupFunction.Functions.ReadingAvailableWebPart(GroupFunctionId, Keyword, ShowAll, PageIndex).value;
    if(retValue.indexOf("ERROR")!=-1)
    {
        alert(retValue);
        return;
    }
    document.getElementById("divProcessingAvailable").innerHTML="";
    document.getElementById("divAvailableGroupFunction").innerHTML=retValue;
}


function JumPageAlreadyGroupFunction(GroupFunctionId)
{
    document.getElementById("divProcessingAlready").innerHTML=Portal.SystemWebParts.GroupFunction.Functions.GetProcessingText().value;
    setTimeout("RealJumPageAlreadyGroupFunction('"+GroupFunctionId+"')",10);
}

function RealJumPageAlreadyGroupFunction(GroupFunctionId)
{
    PageIndex=0;
    if(document.getElementById("divSelectAlreadyGroupFunction")!=null)
    {   
        PageIndex=document.getElementById("divSelectAlreadyGroupFunction").selectedIndex;
    }
    Keyword=document.getElementById("txtAlreadyKeyword").value;
    retValue=Portal.SystemWebParts.GroupFunction.Functions.ReadingAlreadyWebPart(GroupFunctionId,Keyword,PageIndex).value;
    if(retValue.indexOf("ERROR")!=-1)
    {
        alert(retValue);
        return;
    }
    document.getElementById("divProcessingAlready").innerHTML="";
    document.getElementById("divAlreadyGroupFunction").innerHTML=retValue;
}







function AssignWebPartToThisGroupFunction(WebPartId,GroupFunctionId)
{
    retValue=Portal.SystemWebParts.GroupFunction.Functions.ServerSideAddWebPartToGroupFunction(WebPartId,GroupFunctionId).value;
    if(retValue.indexOf("ERROR")!=-1)
    {
        alert(retValue);
        return;
    }
    RealJumPageAvailableGroupFunction(GroupFunctionId);
    RealJumPageAlreadyGroupFunction(GroupFunctionId);
}


function RomoveWebPartFromThisGroupFunction(GroupFunctionId,GroupFunctionItemId)
{
    if(confirm(Portal.SystemWebParts.GroupFunction.Functions.GetConfirmDeleteMsg().value)==false)return;
    retValue=Portal.SystemWebParts.GroupFunction.Functions.ServerSideRemoveWebPartFromGroupFunction(GroupFunctionItemId).value;
    if(retValue.indexOf("ERROR")!=-1)
    {
        alert(retValue);
        return;
    }
    RealJumPageAvailableGroupFunction(GroupFunctionId);
    RealJumPageAlreadyGroupFunction(GroupFunctionId);
}


function ClientConfigFunction(WebPartId, RecordId) {
    Url = Portal.SystemWebParts.GroupFunction.Functions.ServerSideGetConfigUrl(WebPartId, RecordId).value;
    if (Url.indexOf("ERROR") != -1) {
        alert(Url);
        return;
    }
    window.open(Url, '_blank');
}

function ClientSaveDisplayItem(GroupFunctionItemId) {
    if (confirm(Portal.SystemWebParts.GroupFunction.Functions.GetConfirmSaveMsg().value) == false) return;
    DisplayText = document.getElementById("txtDisplayText_" + GroupFunctionItemId).value;
    IndexOrder = document.getElementById("txtIndexOrder_" + GroupFunctionItemId).value;
    belongSiteIndex = document.getElementById("drpSelectSite" + GroupFunctionItemId).selectedIndex;
    SiteCode = document.getElementById("drpSelectSite" + GroupFunctionItemId).options[belongSiteIndex].value;

    retValue = Portal.SystemWebParts.GroupFunction.Functions.ServerSideSaveItemDisplayText(GroupFunctionItemId, DisplayText, IndexOrder, SiteCode).value;
    if (retValue.indexOf("ERROR") != -1) {
        alert(retValue);
        return;
    }
    alert(retValue);
}

function JumpPageLawDocumentItemForShowList() {
}


function ClientInstallWebPart() {
    document.getElementById("divProcessingAvailable").innerHTML = Portal.SystemWebParts.GroupFunction.Functions.GetProcessingText().value;
    setTimeout("RealClientInstallWebPart()", 10);
}

function RealClientInstallWebPart() {
    WebPartId = document.getElementById("txtWebPartInstall").value;
    document.getElementById("divProcessingAvailable").innerHTML = "";
    rValue = Portal.SystemWebParts.GroupFunction.Functions.ServerSideInstallWebPart(WebPartId).value;
    alert(rValue);
}